<?php
class order_model extends CI_Model {

    function __construct()
    {
        parent::__construct();
        
    }
    function getByCuss($CustomerID="")
    {
        $query = $this->db->query("
            SELECT * 
            FROM `dtb_orders` 
            WHERE `Delete` is null
                AND `CustomerID`='$CustomerID'
            ORDER BY `Insert` DESC
        ");
        return $query->result();
    }
    function insert($params){
        $this->db->set('Insert', 'NOW()', FALSE);
        $this->db->set('OrderDate', 'CURDATE()', FALSE);
        $this->db->insert('dtb_orders', $params); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1) return true;
        return false;
    }
}
?>
